package com.fx.service.impl;

import cn.hutool.core.date.DateUtil;
import com.fx.entity.GoodsInfo;
import com.fx.mapper.GoodsInfoMapper;
import com.fx.service.GoodsInfoService;
import com.fx.util.IdWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class GoodsInfoServiceImpl implements GoodsInfoService {
    @Autowired
    private GoodsInfoMapper goodsInfoMapper;
    @Autowired
    private IdWorker idWorker;

    @Override
    public GoodsInfo getById(String flId) {
        return goodsInfoMapper.getById(flId);
    }

    @Override
    public List<GoodsInfo> getList(Map<String, Object> map) {
        return goodsInfoMapper.queryList(map);
    }

    @Override
    public int getCount(Map<String, Object> map) {
        return goodsInfoMapper.queryCount(map);
    }

    @Override
    public int save(GoodsInfo goodsInfo) {
        goodsInfo.setFlId(String.valueOf(idWorker.nextId()));
        goodsInfo.setFlCreatedTime(DateUtil.now());
        return goodsInfoMapper.save(goodsInfo);
    }

    @Override
    public int updateById(GoodsInfo goodsInfo) {
        return goodsInfoMapper.updateById(goodsInfo);
    }

    @Override
    public int remove(String flId) {
        return goodsInfoMapper.remove(flId);
    }

    @Override
    public int batchRemove(String[] flIds) {
        return goodsInfoMapper.batchRemove(flIds);
    }

    @Override
    public List<GoodsInfo> getGoodsByClick(String cstId) {
        return goodsInfoMapper.queryListByClick(cstId);
    }

    @Override
    public List<GoodsInfo> getListByCategory(Map<String, Object> param) {
        return goodsInfoMapper.queryListByCategory(param);
    }

}
